<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // // 展开
        // let arrays = [[1, 2, 3], [4, 5], [6]]
        // console.log(arrays.reduce((item, i) => item.concat(i), []));

        // // 你自己的循环
        // function loop(value, i , p ,console){
        //     for (let item = value;i(item); item = p(item)){
        //         console(item)
        //     }
        // }
        // loop(3, n => n > 0, n => n-1, console.log)

        // function every(array, test) {
        //     for (let item of array) {
        //         if (!test(item)) {
        //             return false
        //         }
        //         return true
        //     }
        // }

        function every(array, test) {
            return !array.some(item => !test(item))
        }
        console.log(every([1, 3, 5], n => n < 10));
        console.log(every([2, 4, 16], n => n < 10));
        console.log(every([], n => n < 10));
    </script>
</body>

</html>